From 7b6efc29cc1ec852ef63ad13a1646df06cfb0f25 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?utf8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 14 Sep 2017 17:43:38 +0000 Subject: [PATCH] GDK W32: Refuse to release mouse grab while in DnD mode Handle WM_CANCELMODE and do nothing in response to it when DnD is active. Otherwise pass it to DefWindowProc, which will call ReleaseCapture() on our behalf. This prevents us from losing mouse capture when alt-tabbing during DnD (this includes the feature of Windows Explorer where dragging stuff over a window button in the taskbar causes that window to receive focus, i.e. keyboardless alt-tabbing). https://bugzilla.gnome.org/show_bug.cgi?id=786509 --- gdk/win32/gdkevents-win32.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index efa4c2f528..873d225227 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -3281,6 +3281,23 @@ gdk_event_translate (MSG *msg, break; + /* + * Handle WM_CANCELMODE and do nothing in response to it when DnD is + * active. Otherwise pass it to DefWindowProc, which will call ReleaseCapture() + * on our behalf. + * This prevents us from losing mouse capture when alt-tabbing during DnD + * (this includes the feature of Windows Explorer where dragging stuff over + * a window button in the taskbar causes that window to receive focus, i.e. + * keyboardless alt-tabbing). + */ + case WM_CANCELMODE: + if (_modal_operation_in_progress & GDK_WIN32_MODAL_OP_DND) + { + return_val = TRUE; + *ret_valp = 0; + } + break; + case WM_CAPTURECHANGED: /* Sometimes we don't get WM_EXITSIZEMOVE, for instance when you select move/size in the menu and then click somewhere without -- 2.30.2